package com.doit.day01;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.Tuple;

import java.util.Set;

public class Hero_Top3 {
    public static void main(String[] args) throws InterruptedException {
        //每隔10s返回一次结果，只返回前三名
        Jedis jedis = new Jedis("linux01", 6379);

        while (true){
            //返回结果   从redis里面获取数据
            Set<Tuple> hero_top3 = jedis.zrevrangeWithScores("hero_top3", 0, 2);
            for (Tuple tuple : hero_top3) {
                String hero = tuple.getElement();
                double count = tuple.getScore();
                System.out.println("英雄是："+hero + "次数是："+count);
            }
            //睡眠6s钟
            Thread.sleep(3000);


        }
    }
}
